#pragma once

#include "Character/Creature.h"
#include "Character/monster/Monster.h"
enum NpcStatus
{
	ENUM_NPC_STATUS_NORMAL = 0, //正常状态
	ENUM_NPC_STATUS_FIGHT = 1, //战斗切换对应关联怪物状态，NPC离开场景,创建怪物战斗
};

class Npc : public Monster
{
public:
	Npc();
	virtual ~Npc();
public:
	//virtual bool CheckAttrValue(uint32_t CANum, uint32_t attrValue) { return true; }
	//virtual bool AddAttr(uint32_t CANum, int64_t attrValue, bool syn, uint64_t relationCid = 0);
	//virtual bool AddAttrMA(uint32_t PANum, int64_t attrValue, bool syn, uint64_t relationCid = 0);
	//virtual bool AddAttrCache(uint32_t CANum, int64_t attrValue, uint64_t relationCid = 0);
	//virtual void SetAttrMA(uint32_t PANum, int64_t attrValue, bool syn = false);
	//virtual void SetAttr(uint32_t CANum, int64_t attrValue, bool syn = false);
	//virtual void SetAttrCache(uint32_t CANum, int64_t attrValue);

	//virtual int64_t  GetAttr(uint32_t CANum) ;
	//virtual int64_t GetPAttrValue(uint32_t attrPANum){ return 0; };
	//virtual uint32_t GetAttrNum(uint32_t CommonAttrNum);

	//bool  AttrsFormula(uint32_t MANum, uint64_t relationCid, bool cache);
	//void  SynAttrCache(uint32_t MANum);

	//获取对应部件指针,part dynamic外部对应转一下

	//视野裁剪接口 后面需要做更复杂的视野裁剪那么子类继承去实现
	virtual bool ViewFliter(Creature* pCreature, float dict);
public:
	virtual bool Init();
	virtual bool UnInit();
	virtual void Update(uint64_t tick);
	virtual void OnDead(CharIDType killerCid);
	virtual void OnCorpse();
	bool	IsInCorpseTime();

	virtual void GetVisibleDataToClient(CreaturesCreateData& cvData);
	virtual bool Born(CharIDType NpcCid, uint32_t npcid, uint32_t sceneId, Point3<float>& bornPos,int32_t npcIdx = -1);
public:
	const NpcNpcCfgInfo* GetNpcInfo() const; //获得配置表中的信息
	const BattlenpcBattlenpcCfgInfo *GetBattleInfo() const;

	//获取怪物模型半径
	virtual float GetModelRadius();
public:
	bool InitConfig(uint32_t npcId);
	uint32_t GetConfigId() const;
	bool IsFunctionType() const;
	bool IsFightType() const;
	uint32_t GetNpcCamp() const;
	uint32_t GetLinkMonsterId() const;
	Point3<float> GetBornPos() const;
	uint32_t GetStatus() const;
	void SetStatus(uint32_t status);
	void SetFacade(const CharOutward & value);
	void DeleteFacade();

public:
	virtual bool IsFriendSide(Creature* pCreature);
	virtual void AddSeeNewCreature(Creature* pCreature);
	void OnExecute(uint16_t nEventID, uint64_t nSrcID, uint8_t bySrcType, void *pContext, int32_t nLen);
	virtual void OnTimer(uint32_t nTimerID);
	//根据配置的公式算出该怪物属性值
	//uint64_t GetMonsterAttrFormula(std::string str);

	virtual void FindCreatureInScene(Uint64Lst& clist);
	virtual uint32_t GetConfigId(){ return m_npcId; }
protected:
	const NpcNpcCfgInfo*	m_npcCfgInfo;
	//Point3<float>			m_bornPos;
	uint32_t				m_npcId;      //NPC 配置表里的id
	uint32_t				m_status; //NPC 状态
	Point3<float>			m_lastPos;
	uint32_t				m_lastSceneId;
	CharOutward * m_pFacade;	//动态外观显示信息
	float m_viewAngle; //视野为扇形时，视野的角度
	uint64_t m_corpseTime; //怪物死亡后尸体到期时间
	const BattlenpcBattlenpcCfgInfo *m_battleInfo;
	int32_t	m_npcIndex;	//npc在地编中的索引
protected:
	//uint64_t m_attrs64[M_ATTR_ULONG_END];
	//uint32_t m_attrs[M_MAX];
	//Part* m_pPart[PART_MAX];

};
